
public class Calculator {
	
	public static double calculatetotalPrice(Food food[], int size)
	{
		double totalPrice=0;
		for(int i=0; i<size; i++)
		{
			totalPrice+=food[i].price;
		}
		return totalPrice;
	}
	public static double calculatetotalCalorie(Food food[], int size)
	{
		double totalCalorie=0;
		for(int i=0; i<size; i++)
		{
			totalCalorie+=food[i].calorie;
		}
		return totalCalorie;
		
	}
	public static double calculatetotalProtein(Food food[], int size)
	{
		double totalProtein=0;
		for(int i=0; i<size; i++)
		{
			totalProtein+=food[i].protein;
		}
		return totalProtein;
	}
	public static double calculatetotalFat(Food food[], int size)
	{
		double totalFat=0;
		for(int i=0; i<size; i++)
		{
			totalFat+=food[i].fat;
		}
		return totalFat;
	}
	public static double calculatetotalCarbohydrate(Food food[], int size)
	{
		double totalCarbohydrate=0;
		for(int i=0; i<size; i++)
		{
			totalCarbohydrate+=food[i].carbohydrate;
		}
		return totalCarbohydrate;
	}
	

	
	
	public static void printName(Food food[], int size)
	{
		
		for(int i=0; i<size; i++)
		{
			System.out.println(food[i].name);
			
		}	
	}
	
	
	public static void printTotalTable(Food food[], int size)
	{
		double totalPrice= calculatetotalPrice(food, size);
		double totalCalorie= calculatetotalCalorie(food, size);
		double totalProtein= calculatetotalProtein(food, size);
		double totalFat= calculatetotalFat(food, size);
		double totalCarbohydrate= calculatetotalCarbohydrate(food, size);
	
		System.out.println("\t price\t calorie\t protein\t fat\t carbohydrate");
		System.out.println("total\t $"+ totalPrice + "\t " + totalCalorie 
							+ "kcal\t " + totalProtein + "g\t\t " + totalFat
							+ "g\t " + totalCarbohydrate+ "g");
	}
	
	
	public static void compare(Food food[], int size)
	{
		// just for test purposes
		double StandardCalorie=6000, StandardProtein=30, StandardFat=20, StandardCarbohydrate=50;
		
		// Now, calcuate total/Standard
		double ratioCalorie= calculatetotalCalorie(food, size)/StandardCalorie;
		double ratioProtein= calculatetotalProtein(food, size)/StandardProtein;
		double ratioFat= calculatetotalFat(food, size)/StandardFat;
		double ratioCarbohydrate= calculatetotalCarbohydrate(food, size)/StandardCarbohydrate;
		
		if(ratioCalorie>=1.5) System.out.println("Your Calorie consumption is much higher than the suggested amount!!");
		else if (ratioCalorie>=1.35) System.out.println("Your Calorie consumption is significantly higher than the suggested amount!!");
		else if (ratioCalorie>=1.2) System.out.println("Your Calorie consumption is slightly higher than the suggested amount!!");
		else if (ratioCalorie<=0.5) System.out.println("Your Calorie consumption is much less than the suggested amount!!");
		else if (ratioCalorie<=0.65) System.out.println("Your Calorie consumption is significantly less than the suggested amount!!");
		else if (ratioCalorie<=0.8) System.out.println("Your Calorie consumption is slightly less than the suggested amount!!");
		else System.out.println("Your Calorie consumption is nice!!");
		
		if(ratioProtein>=1.5) System.out.println("Your Protein consumption is much higher than the suggested amount!!");
		else if (ratioProtein>=1.35) System.out.println("Your Protein consumption is significantly higher than the suggested amount!!");
		else if (ratioProtein>=1.2) System.out.println("Your Protein consumption is slightly higher than the suggested amount!!");
		else if (ratioProtein<=0.5) System.out.println("Your Protein consumption is much less than the suggested amount!!");
		else if (ratioProtein<=0.65) System.out.println("Your Protein consumption is significantly less than the suggested amount!!");
		else if (ratioProtein<=0.8) System.out.println("Your Protein consumption is slightly less than the suggested amount!!");
		else System.out.println("Your Protein consumption is nice!!");
		
		if(ratioFat>=1.5) System.out.println("Your Fat consumption is much higher than the suggested amount!!");
		else if (ratioFat>=1.35) System.out.println("Your Fat consumption is significantly higher than the suggested amount!!");
		else if (ratioFat>=1.2) System.out.println("Your Fat consumption is slightly higher than the suggested amount!!");
		else if (ratioFat<=0.5) System.out.println("Your Fat consumption is much less than the suggested amount!!");
		else if (ratioFat<=0.65) System.out.println("Your Fat consumption is significantly less than the suggested amount!!");
		else if (ratioFat<=0.8) System.out.println("Your Fat consumption is slightly less than the suggested amount!!");
		else System.out.println("Your Fat consumption is nice!!");
		
		if(ratioCarbohydrate>=1.5) System.out.println("Your Carbohydrate consumption is much higher than the suggested amount!!");
		else if (ratioCarbohydrate>=1.35) System.out.println("Your Carbohydrate consumption is significantly higher than the suggested amount!!");
		else if (ratioCarbohydrate>=1.2) System.out.println("Your Carbohydrate consumption is slightly higher than the suggested amount!!");
		else if (ratioCarbohydrate<=0.5) System.out.println("Your Carbohydrate consumption is much less than the suggested amount!!");
		else if (ratioCarbohydrate<=0.65) System.out.println("Your Carbohydrate consumption is significantly less than the suggested amount!!");
		else if (ratioCarbohydrate<=0.8) System.out.println("Your Carbohydrate consumption is slightly less than the suggested amount!!");
		else System.out.println("Your Carbohydrate consumption is nice!!");
		
		
	}
	
}
